import Tool from  'tool/tool.jsx';
const _req = new Tool();

class CategoryService{

   //获取商品列表
   getCategoryList(categoryId){
      return _req.request({
        type: 'post', 
        url : '/manage/category/get_category.do',
        data: { categoryId }
      })
     }
     //修改品类名称
     ChangeCategoryName(categoryInfo){
      return _req.request({
        type: 'post', 
        url : '/manage/category/set_category_name.do',
        data:categoryInfo
      })
     }
     //验证品类添加表单
     onCheckCategory(category){
            if( typeof  category.parentId !== 'number' || !(category.parentId >= 0) ){
              return{
              status: false,
              msg: '请选择正确的商品品类！'
              }    
          }
        if( typeof category.categoryName !== 'string' || category.categoryName.length === 0){
            return{
              status: false,
              msg: '品类名不能为空！'
            }  
        }
          return{
            status: true,
            msg: '验证通过！'
        }
     }
     //添加商品品类
     onSaveCategory(category){
      return _req.request({
        type: 'post', 
        url : '/manage/category/add_category.do',
        data: category
      })
     }
 }


export default CategoryService;